	<?php if(!Yii::app()->user->isGuest){
		$models = Userdata::model()->find('user = '.Yii::app()->user->id);

		if(!empty($models->programs)){
			if(in_array($data->id,json_decode($models->programs))){
				$id = "liked"; 
				$text = "Деинсталирай";
			}else{	
				$id = "liking";
				$text = "Инсталирай";
			}
		}else{	
				$id = "liking";
				$text = "Инсталирай";
		}

    }
	?>

<div class="view">
	<b><?php echo CHtml::encode($data->title); ?></b>

	<a href="#" onclick="openApp(<?php echo $data->id; ?>);return false;">Пусни</a>
	<?php if(!Yii::app()->user->isGuest){ ?>
		<a class="<?php echo $id; ?> static" href="#"  onclick="return false;"><?php echo $text; ?></a>
	<?php }?>
</div>
<script type="text/javascript">
function restart(param){
	if(confirm("<?php echo Yii::t('yii','To complete instalation system need to restart. Reload page?'); ?>")){
		$.get("/system/programs/id/"+param,function(data){
			location.reload(true);
		});	
	}
}

$('a.liked').click(function() {
  restart(<?php echo $data->id; ?>);
});

$('a.liking').click(function() {
  restart(<?php echo $data->id; ?>);
});

</script>
